<?php
    require_once 'controls/global_frontend.php';
    $login_user = new user_controller();
if (isset($_POST['btn_submit'])) {
    $_username = $_POST['username'];
    $_password = $_POST['password'];
    $_ck_remember = 'check';
    $login_user->user_login($_username, $_password , $_ck_remember);
}
if( isset($_COOKIE["username"]) && isset($_COOKIE["password"]) && $_COOKIE["password"] != "out" && $_COOKIE["username"] != "log"){
    //exit;
    $_username = $_COOKIE["username"];
    $_password = $_COOKIE["password"];
    $_ck_remember = "check";
    $login_user->user_login($_username, $_password, $_ck_remember);
}

if(isset($_SESSION['user']))
if (($_SESSION['user']->role == 2)&&($_SESSION['user']->username != "")) {
    $_SESSION['action'] = '';
    $_SESSION['log'] = 'ok';
     header("Location:index.php");
}

?>
<link rel="stylesheet" type="text/css" href="css/registration_form.css" />
<div class="clear"></div>
    <div id="content-outer">
    <div class="center">
        <!-- start content -->
        <div id="content">
            <div id="page-heading"><h1>Login</h1></div>
            <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
                <tr>
                    <th rowspan="3" class="sized"><img src="images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
                    <th class="topleft"></th>
                    <td id="tbl-border-top">&nbsp;</td>
                    <th class="topright"></th>
                    <th rowspan="3" class="sized"><img src="images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
                </tr>
                <tr>
                    <td id="tbl-border-left"></td>
                    <td>
                        <!--  start content-table-inner -->
                        <div id="content-table-inner">
							<div id="message-<?php echo $color?>">
								<table border="0" width="<?php echo $width."%"?>" cellpadding="0" cellspacing="0">
									<tr>
										<td class="<?php echo $color?>-left"><?php echo $message?></td>
										<td class="<?php echo $color?>-right">
											<a class="close-<?php echo $color?>"><img src="images/table/icon_close_<?php echo $color?>.gif"   alt="" />											</a>
										</td>
										</tr>
								</table>
							</div>  
                            <form action="" method="POST">
                                <table border="0" width="100%" cellpadding="0" cellspacing="0">
                                    <tr valign="top">
                                        <td>
                                            <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                                                <tr>
                                        			<th>Username</th>
                                        			<td><input type="text" name="username"  class="login-inp" /></td>
                                        		</tr>
                                        		<tr>
                                        			<th>Password</th>
                                        			<td><input type="password" name="password"  onfocus="this.value=''" class="login-inp" /></td>
                                        		</tr>
                                                <tr>
                                        			<th></th>
                                        			<td valign="top"><input type="checkbox" name="ck_remember" value="check" class="checkbox-size" id="login-check" />
                                                    <label for="login-check" style="font:bold 14px Tahoma;">Remember me</label></td> 
                                                </tr>
                                                <tr>
                                                    <th>&nbsp;</th>
                                                    <td valign="top">
                                                        <input type="submit" name="btn_submit" value="Login" class="form-cancel" />
														<a onclick="location='index.php?action=cancel'" class="form-cancel">Cancel</a>
                                                    </td>
                                                    <td></td>
                                                </tr>
                                            </table>
                                            <!-- end id-form  -->
                                            
                                    <tr>
                                        <td><img src="images/shared/blank.gif" width="695" height="1" alt="blank" /></td>
                                    </tr>
                                </table>
                            </form>
                            <div class="clear"></div>
                        </div>
                        <!--  end content-table-inner  -->
                    </td>
                    <td id="tbl-border-right"></td>
                </tr>
                <tr>
                    <th class="sized bottomleft"></th>
                    <td id="tbl-border-bottom">&nbsp;</td>
                    <th class="sized bottomright"></th>
                </tr>
            </table>
            <div class="clear">&nbsp;</div>
        </div>
        <!--  end content -->
        </div>
        <div class="clear">&nbsp;</div>
        
    </div>